package me.leiusual.sharing.util.extension

import android.content.Context
import android.util.TypedValue
import kotlin.math.roundToInt

/**
 * sp to px
 */
fun Float.spToPx(context: Context): Int {
  val displayMetrics = context.resources.displayMetrics
  return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, this, displayMetrics).roundToInt()
}

/**
 * dp to px
 */
fun Float.dpToPx(context: Context): Int {
  val displayMetrics = context.resources.displayMetrics
  return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, this, displayMetrics).roundToInt()
}